package com.aica.bo;

import com.aica.entity.Role;
import com.aica.entity.User;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Date;
import java.util.List;

/**
 * 用户信息与角色信息整合
 * @author by
 * @date 2021/6/8 0:36
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class UserAndRoleBo {
    /**
     * 用户id
     */
    private Integer userId;
    /**
     * 微信开放平台用户id
     */
    private Integer openId;
    /**
     * 用户名
     */
    private String username;
    /**
     * 昵称
     */
    private String nickName;
    /**
     * 密码
     */
    private String password;
    /**
     * 电话号码
     */
    private String telephone;
    /**
     * 邮箱
     */
    private String email;
    /**
     * 头像图片路径
     */
    private String avatar;
    /**
     * 用户性别
     * 男 女
     */
    private String gender;

    /**
     * 当前日期(新增，记录注册时间)
     */
    private Date registerTime;



    //-----------------

    /**
     * 角色id集合
     */
    private List<Integer> roleIds;
    /**
     * 角色描述集合
     */
    private List<Role> roles;

    public UserAndRoleBo(User user,List<Integer> roleIds,List<Role> roles){
        userId = user.getId();
        openId = user.getOpenId();
        username = user.getUsername();
        nickName = user.getNickName();
        password = user.getPassword();
        telephone = user.getTelephone();
        email =user.getEmail();
        avatar = user.getAvatar();
        gender = user.getGender()==null ?"未填写" : user.getGender() ? "男" : "女";
        registerTime = user.getRegisterTime();
        this.roleIds = roleIds;
        this.roles = roles;
    }
}
